Return to start page

Systems/Debug/Struct System Debugger.j

Code

		
1			library AStructSystemsDebugSystemDebugger requires ALibraryCoreDebugMisc, AStructCoreGeneralHashTable, ALibraryCoreInterfaceMisc, ASystemsCharacter, ASystemsGui, ASystemsWorld
2
3 /// @todo Should be a method of @struct ASystemDebugger, vJass bug.
4 private function onHitActionShowInfo takes AWidget usedWidget returns nothing
5 call usedWidget.gui().showInfoDialog("Advanced Script Library")
6 endfunction
7
8 /// @todo Should be a method of @struct ASystemDebugger, vJass bug.
9 private function onHitActionShowGuiSystemMainWindow takes AWidget usedWidget returns nothing
10 call usedWidget.gui().showMainWindowByIndex(0)
11 endfunction
12
13 /// @todo Should be a method of @struct ASystemDebugger, vJass bug.
14 private function onHitActionShowCharacterSystemMainWindow takes AWidget usedWidget returns nothing
15 call usedWidget.gui().showMainWindowByIndex(1)
16 endfunction
17
18 /// @todo Should be a method of @struct ASystemDebugger, vJass bug.
19 private function onHitActionShowWorldSystemMainWindow takes AWidget usedWidget returns nothing
20 call usedWidget.gui().showMainWindowByIndex(2)
21 endfunction
22
23 /// @todo Should be a method of @struct ASystemDebugger, vJass bug.
24 private function onHitActionInitCharacterSystem takes AWidget usedWidget returns nothing
25 endfunction
26
27 /// @todo Finish code.
28 /// The ASystemDebugger class provides a GUI for testing all systems of the ASL system module.
29 /// You can create characters, NPCs, quests etc. easily by using buttons.
30 /// Usually this reduces debugging time of the programer.
31 struct ASystemDebugger
32 //static start members
33 private static integer menuKey
34 //static members
35 private static thistype array m_playerSystemDebugger[12] /// @todo bj_MAX_PLAYERS
36 //start members
37 private player m_user
38 //members
39 private trigger m_menuTrigger
40 private AMainWindow m_mainWindow
41 private AText m_headLineText
42 private AButton m_guiSystemsButton
43 private AButton m_characterSystemsButton
44 private AButton m_worldSystemsButton
45
46 private AMainWindow m_guiSystemWindow
47 private AText m_guiSystemHeadLineText
48
49 private AMainWindow m_characterSystemWindow
50 private AText m_characterSystemHeadLineText
51 private AButton m_createCharacterButton
52 private AButton m_removeCharacterButton
53
54 private AMainWindow worldSystemWindow
55 private AText worldSystemHeadLineText
56
57 private method showMenu takes nothing returns nothing
58 call AGui.playerGui(this.m_user).dialog().clear()
59 call AGui.playerGui(this.m_user).dialog().setMessage(tr("System-Debugger"))
60 call AGui.playerGui(this.m_user).dialog().addDialogButton(tr("GUI-System"), 0, 0)
61 call AGui.playerGui(this.m_user).dialog().addDialogButton(tr("Charaktersystem"), 0, 0)
62 call AGui.playerGui(this.m_user).dialog().addDialogButton(tr("Weltsystem"), 0, 0)
63 call AGui.playerGui(this.m_user).dialog().show()
64 endmethod
65
66 private method createGuiSystemWindow takes nothing returns nothing
67 set this.m_guiSystemWindow = AMainWindow.create(AGui.playerGui(this.m_user), 0.0, 0.0, 1000.0, 1000.0, true, 0)
68
69 set this.m_guiSystemHeadLineText = AText.create(this.m_mainWindow, 400.0, 200.0, 0.0, 0.0, 0, onTrackActionShowTooltip)
70 call this.m_guiSystemHeadLineText.setTextAndSize("GUI-System", 15.0)
71 call this.m_guiSystemHeadLineText.setTooltip("Die ASL bietet ein GUI-System, welches zum Erstellen grafischer Oberflächen verwendet werden kann.")
72 call this.m_guiSystemHeadLineText.setTooltipSize(12.0)
73
74 //show all kinds of widgets
75 endmethod
76
77 private method createCharacterSystemWindow takes nothing returns nothing
78 set this.m_characterSystemWindow = AMainWindow.create(AGui.playerGui(this.m_user), 0.0, 0.0, 1000.0, 1000.0, true, 0)
79 endmethod
80
81 private method createWorldSystemWindow takes nothing returns nothing
82 endmethod
83
84 private method createGui takes nothing returns nothing
85 set this.m_mainWindow = AMainWindow.create(AGui.playerGui(this.m_user), 0.0, 0.0, 1000.0, 1000.0, true, -1)
86
87 set this.m_headLineText = AText.create(this.m_mainWindow, 400.0, 200.0, 0.0, 0.0, onHitActionShowInfo, onTrackActionShowTooltip)
88 call this.m_headLineText.setTextAndSize("Advanced Script Library", 15.0)
89 call this.m_headLineText.setTooltip("Advanced Script Library.")
90 call this.m_headLineText.setTooltipSize(12.0)
91
92 set this.m_guiSystemsButton = AButton.create(this.m_mainWindow, 50.0, 50.0, 20.0, 20.0, onHitActionShowGuiSystemMainWindow, onTrackActionShowTooltip)
93 call this.m_guiSystemsButton.setShortcut('g')
94 call this.m_guiSystemsButton.setTooltip("Drücken Sie hier, um das GUI-System der ASL zu testen")
95 call this.m_guiSystemsButton.setTooltipSize(12.0)
96
97 set this.m_characterSystemsButton = AButton.create(this.m_mainWindow, 50.0, 50.0, 20.0, 20.0, onHitActionShowCharacterSystemMainWindow, onTrackActionShowTooltip)
98 call this.m_characterSystemsButton.setShortcut('c')
99 call this.m_characterSystemsButton.setTooltip("Drücken Sie hier, um das Charaktersystem der ASL zu testen.")
100 call this.m_characterSystemsButton.setTooltipSize(12.0)
101
102 set this.m_worldSystemsButton = AButton.create(this.m_mainWindow, 100.0, 50.0, 20.0, 20.0, onHitActionShowWorldSystemMainWindow, onTrackActionShowTooltip)
103 call this.m_worldSystemsButton.setShortcut('w')
104 call this.m_worldSystemsButton.setTooltip("Drücken Sie hier, um das Weltsystem der ASL zu testen.")
105 call this.m_worldSystemsButton.setTooltipSize(12.0)
106
107 call this.createGuiSystemWindow()
108 call this.createCharacterSystemWindow()
109 call this.createWorldSystemWindow()
110 endmethod
111
112 private static method triggerActionShow takes nothing returns nothing
113 local trigger triggeringTrigger = GetTriggeringTrigger()
114 local thistype systemDebugger = AHashTable.global().handleInteger(triggeringTrigger, "this")
115 call systemDebugger.showMenu()
116 set triggeringTrigger = null
117 endmethod
118
119 private method createMenuTrigger takes nothing returns nothing
120 local event triggerEvent
121 local triggeraction triggerAction
122 set this.m_menuTrigger = CreateTrigger()
123 set triggerEvent = TriggerRegisterKeyEventForPlayer(this.m_user, this.m_menuTrigger, thistype.menuKey, true)
124 set triggerAction = TriggerAddAction(this.m_menuTrigger, function thistype.triggerActionShow)
125 call AHashTable.global().setHandleInteger(this.m_menuTrigger, "this", this)
126 set triggerEvent = null
127 set triggerAction = null
128 endmethod
129
130 /// @param user The debugging player.
131 public static method create takes player user returns thistype
132 local thistype this = thistype.allocate()
133 //start members
134 set this.m_user = user
135
136 call this.createMenuTrigger()
137 call this.createGui()
138 return this
139 endmethod
140
141 private method destroyMenuTrigger takes nothing returns nothing
142 call AHashTable.global().destroyTrigger(this.m_menuTrigger)
143 set this.m_menuTrigger = null
144 endmethod
145
146 public method onDestroy takes nothing returns nothing
147
148 call this.destroyMenuTrigger()
149 //main window is destroyed when gui is destroyed
150 endmethod
151
152 /// @param menuKey The key which should be pressed by the player for showing the debugger's GUI.
153 public static method init takes integer menuKey returns nothing
154 local integer i
155 local player user
156 //static start members
157 set thistype.menuKey = menuKey
158 //static members
159 set i = 0
160 loop
161 exitwhen (i == bj_MAX_PLAYERS)
162 set user = Player(i)
163 if (IsPlayerPlayingUser(user)) then
164 set thistype.m_playerSystemDebugger[i] = 0
165 endif
166 set user = null
167 set i = i + 1
168 endloop
169 endmethod
170
171 public static method playerSystemDebugger takes integer playerId returns thistype
172 local player user
173 if (thistype.m_playerSystemDebugger[playerId] == 0) then
174 set user = Player(playerId)
175 set thistype.m_playerSystemDebugger[playerId] = thistype.create(user)
176 set user = null
177 endif
178 return thistype.m_playerSystemDebugger[playerId]
179 endmethod
180 endstruct
181
182 endlibrary